package com.janj.service;

import com.github.pagehelper.PageHelper;
import com.janj.bean.Hero;
import com.janj.dao.HeroMapper;
import com.janj.util.MyBatisUitls;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class HeroServiceImpl implements HeroService {
    @Override
    public List<Hero> selectAll() {
        //1.获取到执行者 session
        SqlSession session = MyBatisUitls.getSQLSession();

        //2.准备执行SQL --> getMapper(...)
        HeroMapper mapper = session.getMapper(HeroMapper.class);

        PageHelper.startPage(1,8);

        //3.调用方法执行SQL
        List<Hero> array = mapper.selectAll();

        //4.释放资源
        MyBatisUitls.close();
        return array;
    }
}
